import { MockMethod } from 'vite-plugin-mock'
import { ResultEnum, ResponseEnum } from '@/enums/HttpEnum'
const BASE_URL = '/mock-api'
const userList: {
  userName: string
  password: string
  role: string
  roleId: string
  permissions: string | string[]
}[] = [
  {
    userName: 'admin',
    password: 'admin',
    role: 'admin',
    roleId: '1',
    permissions: ['*.*.*']
  }
]

export default [
  {
    url: BASE_URL + '/auth/login',
    method: 'post',
    timeout: ResponseEnum.TIMEOUT,
    response: ({ body }) => {
      let hasUser = false
      for (const user of userList) {
        if (user.userName === body.userName && user.password === body.password) {
          hasUser = true
          return {
            code: ResultEnum.SUCCESS,
            data: {
              scope: null,
              openid: null,
              accessToken:
                'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJzeXNfdXNlcjoxIiwicm5TdHIiOiI4SnJndGtKSVJiVWdJZ3dZNTZzZWd2aDlncnBtYkVjYyIsImNsaWVudElkIjoiZTVjZDdlNDg5MWJmOTVkMWQxOTIwNmNlMjRhN2IzMmUiLCJ0ZW5hbnRJZCI6MCwidXNlcklkIjoxLCJ1c2VyTmFtZSI6InN1cGVyYWRtaW4iLCJkZXB0SWQiOjEsImRlcHROYW1lIjoiWFjpg6jpl6gifQ.byFTVpJ0SAbVwxIWnvBOZoqd_RbdUlyrHO7qbYhCiCg',
              refreshToken: null,
              tokenType: 'Bearer',
              expireIn: 604799,
              refreshExpireIn: null,
              clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e'
            },
            msg: '操作成功'
          }
        }
      }
      if (!hasUser) {
        return { code: ResultEnum.ERROR, data: null, msg: '账号或密码错误' }
      }
    }
  },
  {
    url: BASE_URL + '/auth/logout',
    method: 'post',
    timeout: ResponseEnum.TIMEOUT,
    response: () => {
      return {
        code: ResultEnum.SUCCESS,
        data: null,
        msg: '操作成功'
      }
    }
  },
  {
    url: BASE_URL + '/captchaImage',
    method: 'get',
    timeout: ResponseEnum.TIMEOUT,
    response: () => {
      return {
        code: ResultEnum.SUCCESS,
        data: {
          captchaEnabled: true,
          uuid: '1783e845dc044868979847b93877afb1',
          img: 'iVBORw0KGgoAAAANSUhEUgAAAKAAAAA8CAYAAADha7EVAAAJ7ElEQVR4Xu2c/XMV1RnHnU5t/4H2B622dfqDdei0nWmroJaK2EG0g+iQBKvgSxGITlKYEQ2OVHkR0BlpQd5EMEKhBfICSQCTUqQyAwHatMQinQSpvIiJebt5kQvJvbmn99nOczl5nnN2z2527+Xe7A+fydy93+c5zPCZc3f3nN3rxK5dIiQkU1xHD4SEpJNQwJCMEgoYklFCAUMySihgSEYJBQzJKKGAIRlj4vOtoYAhmSMUMCRjgHzwNxQwJO2gfICRgImd1eLywsOi54mPRef9Z0X73S2ibXSr6Bj3mYg8/In4ck6DiJe+z+pCdonBynLRunqROFEyRRx85qei9vFbRU3eTdZf+HyiJC/5/WIrR2tzEVk+wF7Ait3iUslx0T72omi7/Qt7kkL2FTaKRHkV7zNC+WLNEnHgqR+Jqik3OHLg6R+LtnXLWI9cgsoHaAUc3LbHmt2YaA50TTojEttrWL+RRtPimUwyE5pfK2S9cgVjAUG+zglnmVymdBc0C1G5m/UdKTQvnsXEcsPp155lPbMdlXwAFzD5sxuZ7H7mo1x+5TAbbCTQueFNUT3lRiaVG6rzviW63lnBemczxgJeeuHvTCYvdIy7YMlM++c6h2aNYUJ54dDsO1nvbMZIwMSfa0T7zz9nMiG9vzkp4u/UJq+Kq0Rs3X7Rnd/EMjLTflgmbhm1MgUdPNdoX7eciSTzrxcfEb2la0S8bIf1958vPMwyMu3rX2djZCM6+YAhAkbnH2USIV/+toEVw3le5BH9z3XvjI+G5HNdxIbnJzGJkH+//BjLA43z81kWaZj3EMtnI8YCwhUslQjonHhWe1FxZfmHLJ+qe+CslSn6x/WO0L7ZRqKyQuz79feYRMCeqd8RAzv/xGqA/u1/FDUFN7MaAPpBX1qTbRgJOLh1r2i7g0sERF86ygpTdckr5nM/u2hJGslrFr1Pn7Rmy+jLR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Hqd70XDIUMGCyWUAARKIyOdWr8oEJ6EYsN9mgCAW8ik4gCsijEpHWqzJYT48hoYABM1wBQSzTHm4lpALpkAVCyVTQOlU9JRQwDZgKpMKNVG6ygKmAgEoik3pVnUwoYJrwIiHUuJEKspt2rdRC8yYCISqRTOpVdTKhgGnEjYSYNREQBXPKUhlNBJIBmWSh7OppVsewBQRMxDLJpINMCgiAWHYi0u9NpDLNqursJNIBYunqTMUb++o5i1DADIGiUWhOJRWdyeyydkC9TiQnoA5lk6E5CoqHn/8HDAWral6yiMIAAAAASUVORK5CYII='
        },
        msg: '操作成功'
      }
    }
  }
] as MockMethod[]
